local more1__fenli = fk.CreateSkill {
  name = "more1__fenli",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["more1__fenli"] = "奋力",
  [":more1__fenli"] = "锁定技，当你使用转化牌时，你令此牌获得以下至多两项："..
  "1、此牌伤害基数+1。"..
  "2、此牌结算后目标恢复一点体力。"..
  "3、此牌不可被响应。"..
  "4、此牌无视防具。"..
  "5、此牌结算后使用者摸两张牌。"..
  "6、此牌额外指定至多三个目标。"..
  "7、此牌结算后使用者此阶段使用【杀】的次数+1，若使用者为你，则本局游戏你使用【杀】次数永久+1。",

  ["#more1__fenli-choice"] = "奋力：请选择至多两项效果",

  ["more1__fenli_damage"] = "伤害基数+1",
  ["more1__fenli_recover"] = "恢复一点体力",
  ["more1__fenli_response"] = "不可被响应",
  ["more1__fenli_armor"] = "无视防具",
  ["more1__fenli_draw"] = "摸两张牌",
  ["more1__fenli_targets"] = "额外指定至多三个目标",
  ["more1__fenli_slash"] = "此阶段使用【杀】的次数+1",

  ["$more1__fenli1"] = "",
  ["$more1__fenli2"] = ""
}


more1__fenli:addEffect(fk.CardUsing, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(more1__fenli.name) and data.card:isConverted() and data.from == player 
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local all_choices = {
      "more1__fenli_damage",
      "more1__fenli_recover",
      "more1__fenli_response",
      "more1__fenli_armor",
      "more1__fenli_draw",
      "more1__fenli_targets",
      "more1__fenli_slash",
    }
    local choiceList = table.simpleClone(all_choices)
    local targets = UseCardData:new(data):getExtraTargets()
    if (#targets == 0) then
      table.remove(choiceList, 6)
    end
    local choices = room:askToChoices(player, {
      choices = choiceList,
      min_num = 1,
      max_num = 2,
      skill_name = more1__fenli.name,
      prompt = "#more1__fenli-choice",
      cancelable = true,
    })
    if #choices > 0 then
      event:setCostData(self, { choice = choices })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local choices = event:getCostData(self).choice
    data.extra_data = data.extra_data or {}
    data.extra_data.more1__fenli = data.extra_data.more1__fenli or {}
    local targets = UseCardData:new(data):getExtraTargets()
    for _, choice in ipairs(choices) do
      if choice == "more1__fenli_damage" then
        data.additionalDamage = (data.additionalDamage or 0) + 1
      end

      if choice == "more1__fenli_recover" then
        data.extra_data.more1__fenlibuff[choice] = true
      end 

      if choice == "more1__fenli_disresponsive" then
        data.disresponsiveList = room:getAlivePlayers(false)
      end

      if choice == "more1__fenli_armor" then
        for _, p in ipairs(room.alive_players) do
          room:addTableMark(p, MarkEnum.MarkArmorInvalidFrom, player.id)
        end
        room.logic:getCurrentEvent():findParent(GameEvent.UseCard, true):addCleaner(function()
          for _, p in ipairs(room.alive_players) do
            room:removeTableMark(p, MarkEnum.MarkArmorInvalidFrom, player.id)
          end
        end)
      end 

      if choice == "more1__fenli_draw" then
        data.extra_data.more1__fenlibuff[choice] = true
      end

      if choice == "more1__fenli_targets" then
        local to = room:askToChoosePlayers(player, {
          min_num = 1,
          max_num = 3,
          targets = targets,
          skill_name = more1__fenli.name,
          prompt = "#more1__fenli_target",
          cancelable = false,
        })
        table.insert(data.tos, to)
        room:sortByAction(data.tos)
      end 

      if choice == "more1__fenli_slash" then
        if data.from == player then
          room:addPlayerMark(player, MarkEnum.SlashResidue, 1)  
        else
          room:addPlayerMark(data.from, MarkEnum.SlashResidue .. "-phase", 1)  
        end
      end 
    end
  end,
})

more1__fenli:addEffect(fk.CardUseFinished, {
  mute = true,
  is_delay_effect = true,
  can_trigger = function(self, event, target, player, data)
    return data.extra_data and data.extra_data.more1__fenlibuff and
      (data.extra_data.more1__fenlibuff.more1__fenli_draw == true or
        data.extra_data.more1__fenlibuff.more1__fenli_recover == true)
      and not player.dead
  end,
  on_use = function (self, event, target, player, data)
    if data.extra_data.more1__fenlibuff.more1__fenli_draw == true then
      player:drawCards(2, more1__fenli.name)
    end
    if data.extra_data.more1__fenlibuff.more1__fenli_recover == true then
      player.room:recover{
        who = data.from,
        num = 1,
        recoverBy = data.from,
        skillName = more1__fenli.name,
      }
    end
  end,
})





return more1__fenli
